package com.example.eurekaconsumer;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class ConsumerController {

    @Resource
    private RestTemplate restTemplate;

    @Resource
    private ConsumerService consumerService;

    @RequestMapping(value = "/consumerRibbon", method = RequestMethod.GET)
    public String consumer() {
        return restTemplate.getForEntity("http://eureka-producer/hello", String.class).getBody();
    }


    @RequestMapping(value = "/consumerHystrix", method = RequestMethod.GET)
    public String consumerHystrix() {
        return consumerService.consumer();
    }

}
